/**
 * 获得GA头像工具
 */
package cn.xiazhengxin.blog.util

import java.security.*

/**
 * @author sharl
 *
 */
class Gravatar {
	
	  static String hex(byte[] array) {        
	      StringBuffer sb = new StringBuffer();        
	      for (int i = 0; i < array.length; ++i) {            
		  sb.append(Integer.toHexString((array[i] 
		      & 0xFF) | 0x100).substring(1,3));        
	      }        
	      return sb.toString();    
	  }    
	  
	  static String md5Hex(String message) {         
	      try {             
		  MessageDigest md = 
		      MessageDigest.getInstance("MD5");             
		  return hex(md.digest(message.getBytes("CP1252")));         
	      } catch (NoSuchAlgorithmException e) {         
	      } catch (UnsupportedEncodingException e) {         
	      }         
	      return null;    
	  }
}
